<?php

    include_once '../connection/databaseHandler.php';
    include_once '../connection/sessionHandler.php';
    $database   = new DatabaseHandler();
    $session    = new SessionHandler();

    $from       = $session->username;
    $to         = $_GET['to'];
    $message    = $_GET['message'];

    $to         = stripslashes($to);
    $message    = stripslashes($message);
    $to         = mysql_escape_string($to);
    $message    = mysql_escape_string($message);

    $query1     = "INSERT INTO ".$database->t_chat."(id,username,content,date) VALUE (NULL,'".$from."','".$message."',NOW())";
    $query2     = "INSERT INTO ".$database->t_chatfor."(id_chat,to_username) VALUE (LAST_INSERT_ID(),'".$to."')";
    $database->execQuery($query1);
    $database->execQuery($query2);

    echo "berhasil mengirim pesan...";
    
?>
